package com.geeksaga.dao.ibatis.oracle;

import java.util.List;

import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Repository;

import com.geeksaga.dao.FileDao;
import com.geeksaga.dao.ibatis.BaseIBatisDao;
import com.geeksaga.domain.SagaFile;

/**
 * @author newbie
 * @since 0.1
 */
@Repository
public class FileDaoImpl extends BaseIBatisDao implements FileDao {

	/* (non-Javadoc)
	 * @see com.geeksaga.dao.BbsFileDao#add(com.geeksaga.domain.BbsFile)
	 */
	public SagaFile add(SagaFile file) throws DataAccessException {
		return (SagaFile) getSqlMapClientTemplate().insert("SAGA_FILE.add", file);
	}

	/* (non-Javadoc)
	 * @see com.geeksaga.dao.BbsFileDao#find(com.geeksaga.domain.Bbs)
	 */
	@SuppressWarnings("unchecked")
	public List<SagaFile> find(SagaFile file) throws DataAccessException {
		return (List<SagaFile>) getSqlMapClientTemplate().queryForList("SAGA_FILE.find", file);
	}

    /* (non-Javadoc)
     * @see com.geeksaga.dao.BbsFileDao#findBySid(java.lang.String)
     */
    public SagaFile findBySid(String sid) throws DataAccessException {
        return (SagaFile) getSqlMapClientTemplate().queryForObject("SAGA_FILE.findBySid", sid);
    }
}